#pragma once
#ifdef _MSC_VER
#	pragma warning(push)
#	pragma warning(disable : 4244) // 'argument' : conversion from 'type1' to 'type2'
#endif
#include <boost/iostreams/stream.hpp>
#ifdef _MSC_VER
#	pragma warning(pop)
#endif
#include "FileDevice.h"
#include "ImportExport.h"

namespace ja2{ namespace vfs
{
	//! File stream. Used for all file I/O operations.
	typedef boost::iostreams::stream<FileDevice> FileStream_t;
	//! File stream iterator
	class FileStreamIterator : public boost::iterator_facade<FileStreamIterator, FileStream_t::char_type const, boost::forward_traversal_tag>
	{
		// Attributes
	private:
		//! File handle.
		FileStream_t *m_pFile;
		//! Position.
		boost::iostreams::stream_offset m_Position;
		//! Character read.
		char m_Char;

		// Operations
	private:
		//! Increment.
		JA2_VFS_API void increment();
		//! Equality operation.
		JA2_VFS_API bool equal(FileStreamIterator const &Right) const;
		//! Dereference.
		JA2_VFS_API char const &dereference() const;

		// Construction
	public:
		JA2_VFS_API FileStreamIterator(FileStream_t *pFile, boost::iostreams::stream_offset Position);

		friend class boost::iterator_core_access;
	};

	//! Get beginning iterator for file.
	JA2_VFS_API FileStreamIterator file_begin(FileStream_t *pFile);
	//! Get ending iterator for file.
	JA2_VFS_API FileStreamIterator file_end(FileStream_t *pFile);
} /*vfs*/} /*ja2*/